<template>
  <div class="user">
    <h2>用户信息</h2>
    <ul class="info">
      <li><span>姓名</span><span>{{user.username}}</span></li>
      <li><span>联系方法</span><span>{{user.telephone}}</span></li>
      <li><span>邮箱</span><span>{{user.email}}</span></li>
      <li>
        <span>操作</span>
        <span>
          <el-button size="mini" type="danger" @click="deleteManageUser">删除</el-button>
          <el-button
                size="mini"
                @click="findShopFans(user.id, 1)"
                
                v-if="user.status === 0"
                >禁用</el-button
              >
              <el-button
                size="mini"
                @click="findShopFans(user.id, 0)"
                v-else
                >取消禁用</el-button
              >
        </span>
      </li>
    </ul>
  </div>
</template>
<script>
import {ReqInforoId} from '../../../request/index'
export default {
    data(){
        return{
            user:{}
        }
    },
    methods:{
       async resInfoId(){
           let id  = this.$router.history.current.query.id
           let res =await ReqInforoId(id)
           this.user = res.userInfo
       },
        // 删除用户
    async deleteManageUser() {
      this.$confirm("此操作将永久删除该用户, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(async () => {
          await ReqDeleteUser(user.id);
          this.$message({
            type: "success",
            message: "删除成功!",
          });
          await this.resInfoId()
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
       // 修改状态
    async findShopFans(id, status) {
      console.log(id, status);
      let result = await ReqProhibitUser({ id, status });
      const { msg } = result;
      if (msg === "success") {
        this.$message({
          message: "修改用户状态成功",
          type: "success",
        });
       await this.resInfoId()
      }
    },
    },
    created(){
        this.resInfoId()
    }
}
</script>
<style scoped>
.user {
  width: 90%;
  margin: 0 auto;
}
.user h2 {
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  padding-top: 10px;
}
.user .info li {
  height: 60px;
  line-height: 60px;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #eee;
}
</style>